

package FuenteDeDatos;
import java.sql.SQLException;
import java.util.Observable;
import java.util.Observer;

public class DataRadioButton extends javax.swing.JRadioButton implements Observer{

     private String campo;
    private DataSource data=null;
    private String valor;
    //private datasource data2;



     public void conectar(){

         this.getData().addObserver(this);
        //getData().addObserver(this);

     }


    public void update(Observable o, Object o1) {

        this.setSelected(false);


        try {

           // data2 = (datasource) o;

            String dato=(this.data.rs.getString(this.getCampo()));
            if(dato.equals(getValor())){
                  this.setSelected(true);

            }else{
                  this.setSelected(false);
            }

            //this.setText(this.data.consulta().getString(this.getCampo()));


        } catch (SQLException ex) {
             this.setSelected(false);
        }
    }


    public String getCampo() {
        return campo;
    }

    /**
     * @param campo the campo to set
     */
    public void setCampo(String campo) {
        this.campo = campo;
    }


    public DataSource getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(DataSource data) {
        this.data = data;
        if(data!=null){
            this.conectar();

        }
    }

    /**
     * @return the valor
     */
    public String getValor() {
        return valor;
    }

    /**
     * @param valor the valor to set
     */
    public void setValor(String valor) {
        this.valor = valor;
    }

    /**
     * @return the bande
     */


}
